﻿namespace assignment_2_2
{
    internal class Program_2
    {
        public static void ArrCalculat(double[] a, out double max, out double min, out double ave, out double sum)
        {
            double tmp = a[0];
            for (int i = 1; i < a.Length; i++)
            {
                if (a[i] > tmp)
                {
                    tmp = a[i];
                }
            }
            max = tmp;

            tmp = a[0];
            for (int i = 1; i < a.Length; i++)
            {
                if (a[i] < tmp)
                {
                    tmp = a[i];
                }
            }
            min = tmp;

            sum = 0;
            for (int i = 0; i < a.Length; i++)
            {
                sum += a[i];
            }

            ave = sum / a.Length;
        }

        private static void Main()
        {
            double[] aimArr = new double[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
            double max, min, ave, sum;
            ArrCalculat(aimArr, out max, out min, out ave, out sum);
            Console.WriteLine($"最大值：{max} 最小值：{min} 平均值：{ave} 和：{sum}");
        }
    }
}